﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Serilog;

namespace SeriLog.Demo.Services
{
    public class WeatherForecastService
    {
        private static readonly string[] Summaries = new[]
        {
            "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
        };
        public IEnumerable<WeatherForecast> Get()
        {
            var rng = new Random();
            var array = Enumerable.Range(1, 5000).Select(index => new WeatherForecast
            {
                Date = DateTime.Now.AddDays(index),
                TemperatureC = rng.Next(-20, 55),
                Summary = Summaries[rng.Next(Summaries.Length)]
            })
            .ToArray();
            foreach (var item in array)
            {
                //_logger.LogInformation(item.Date.ToLongDateString());
                //结构化数据返回
                Log.Information("In my bowl I have {@item}", item);
            }

            //结构化数据返回
            Log.Information("In my bowl I have {@array}", array);
            return array;
        }
    }
}
